package com.bilibili.lambda;

import com.bilibili.innerclass.Student;

import java.util.Arrays;
import java.util.Comparator;

public class Lambdademo2 { public static void main(String[] args) {
    Student[] students = new Student[6];
    students[0] = new Student("bro1", 20, 173, '男');
    students[1] = new Student("gir1", 23, 168, '女');
    students[2] = new Student("gir2", 24, 172, '女');
    students[3] = new Student("bro2", 22, 180, '男');
    students[4] = new Student("gir3", 21, 165, '女');
    students[5] = new Student("gir4", 25, 166, '女');

    Arrays.sort(students, (Student o1, Student o2)-> {
        return o1.getAge() - o2.getAge();
    });

        for (int i = 0; i < students.length; i++) {
        Student s = students[i];
        //System.out.println(s);
        System.out.println(s.getName()+"\t"+s.getSex()+"\t"+s.getAge()+"\t"+s.getHight());
        }
    }
}
